<!DOCTYPE html>
<html>
<head>
  <title>设置管理</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" th:href="@{/bootstrap4/css/bootstrap.min.css}">
  <link rel="stylesheet" th:href="@{/css2/style2.css}"> 
  <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.js"></script>
  <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
  <script th:src="@{/js2/my.js}"></script>
</head>

<script type="text/javascript">

function submitComm(id) {
  var value=$("#"+id).val();
  <!--无不返还 -->
  if(!value){
	  return;
  }
  var equipment = $("#equipment").val();
  var commandType =  $("#"+id).attr("commandType");
  var ass="commandMesg="+id+"&commandId="+value
  		+"&commandName="+ equipment+"&commandType="+ commandType;
  console.log(ass);
  $.ajax({
      //几个参数需要注意一下
          type: "POST",//方法类型
          dataType: "json",//预期服务器返回的数据类型
          url: "sendEquipment" ,//url
          data: ass,
          success: function (result) { 
              console.log(result);//打印服务端返回的数据(调试用)
              $("#txt"+id).html('&nbsp;&nbsp;' + result.msg); 
              setTimeout(function(){ $("#txt"+id).html("")} , 1000 );
              <!--
              if(result.data){
            	  $("#"+id).val(result.data); 
              }
              -->
          },
          error : function() {
              alert("异常！");
          }
      });
} 


function readComm() {
	 var equipment = $("#equipment").val();
	 var commandGroup = $("#commandGroup").val(); 
	 window.location.href = "setEquipmentInfo?equipment="+equipment+"&commandGroup=" + commandGroup;
} 
</script>
<body>
<div class="header-area" id="headerArea">
   <div class="container h-100 d-flex align-items-center justify-content-between">
 
     <div class="logo-wrapper">
     <a th:href="@{/edit?equipment=} + ${equipment}"> 返回 </a>
	 </div>
     <!-- Search Form-->
     <div class="top-search-form">
     	设备设置管理
     </div>
     <div  id="suhaNavbarToggler"><span></span><span></span><span></span></div>
   </div>
 </div>

<div class="container mt60">
  <form id="formID"  >
  	<input type="hidden" id="equipment" name="equipment" th:value="${equipment}" />
  	<input type="hidden" id="commandGroup" name="commandGroup" th:value="${commandGroup}" />  
  	 
    <div class="form-group">
       <div class="single-payment-method"> 
       		<img class="mb-3" th:src="@{/img/bg-img/15.jpeg}" width="100%" alt="">
       </div>
    </div> 
    
    	<div class="form-group"  >
      	<button type="button" class="btn btn-primary btn-block" onclick="readComm()" >读取</button>
    </div>
    
    
    
	<div class="form-group" th:each="commandInfo : ${commandInfoList}">
	
      <label class="title fl"></label>
      <label  th:for="${commandInfo.commandMesg}" class="fl" >
      	<span th:text="${commandInfo.commandName}"></span>:
      </label>
      
       <div th:id="${'txt'+commandInfo.commandMesg}" class="fl clred pl10"> 
       </div>
       
      <div class="fr"> <button type="button" class="btn btn-primary" 
       th:onclick="submitComm([[${commandInfo.commandMesg}]])" >发送</button>
       </div>
      
      
      
      <input  th:if="${commandInfo.areaType} != 2" 
      type="text" class="form-control" 
      th:id="${commandInfo.commandMesg}" 
      th:placeholder="请填 + ${commandInfo.commandName}" 
      th:name="${commandInfo.commandMesg}"      
      th:attr="commandType = ${commandInfo.commandType}" 
      th:value="${commandInfo.standbyfield1}"
      >
      
     <select th:if="${commandInfo.areaType} == 2"
     	 th:id="${commandInfo.commandMesg}" 
	     th:name="${commandInfo.commandMesg}"  
	     th:attr="commandType = ${commandInfo.commandType}" 
	     th:value="${commandInfo.standbyfield1}"
	     class="form-control" > 
	     
	    <option value="" >请选择</span></option>
		<option th:each="channel:${['map'+commandInfo.commandMesg]}"  
		th:selected="${commandInfo.standbyfield1 == channel.key}"
		th:value="${channel.key}"  
		th:text="${channel.value}">
		</option>
		
	 </select>
	 
    
	</div> 
  </form>
 
</div>

</body>
</html>
   
 
 
 
